package com.example.stream.demostream.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.stream.demostream.entity.query.SysPlugCategoryQuery;
import com.zhe.log.annotation.Log;
import com.zhe.log.annotation.LogBizModule;
import com.zhe.web.common.ApiResponse;
import com.zhe.web.common.ListResponse;
import com.zhe.web.common.PageResponse;
import com.zhe.web.common.Pagination;
import com.zhe.web.common.vo.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.example.stream.demostream.entity.SysPlugCategory;
import com.example.stream.demostream.service.SysPlugCategoryService;

import java.util.Arrays;
import java.util.Collection;
import java.util.List;

/**
 * <p>
 * 插件分类表 前端控制器
 * </p>
 *
 * @author chenxiaohua
 * @since 2021-09-28
 */
@LogBizModule("插件分类")
@RestController
@RequestMapping("/sysPlugCategory")
@Api(value = "插件分类表 前端控制器",tags = "插件分类表 SysPlugCategory")
public class SysPlugCategoryController {

    @Autowired
    private SysPlugCategoryService sysPlugCategoryService;

    @Log("保存或修改")
    @ApiOperation(value = "保存或修改", notes = "保存或修改")
    @PostMapping("/saveOrUpdate")
    public ApiResponse<Boolean> saveOrUpdate(@RequestBody @Validated SysPlugCategory entity) {
        boolean result = sysPlugCategoryService.saveOrUpdate(entity);
        return ApiResponse.success(result);
    }

    @ApiOperation(value = "保存", notes = "保存")
    @PostMapping("/save")
    public ApiResponse<Boolean> save(@RequestBody @Validated SysPlugCategory entity) {
        boolean result = sysPlugCategoryService.save(entity);
        return ApiResponse.success(result);
    }

    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("/update")
    public ApiResponse<Boolean> update(@RequestBody @Validated SysPlugCategory entity) {
        boolean result = sysPlugCategoryService.updateById(entity);
        return ApiResponse.success(result);
    }

    @ApiOperation(value = "根据ID逻辑删除", notes = "根据ID逻辑删除")
    @PostMapping("/remove/{id}")
    public ApiResponse<Boolean> removeById(@PathVariable Long id) {
        boolean result = sysPlugCategoryService.removeById(id);
        return ApiResponse.success(result);
    }

    @ApiOperation(value = "根据多个ID批量逻辑删除", notes = "根据多个ID批量逻辑删除")
    @PostMapping("/batchRemoveById")
    public ApiResponse<Boolean> batchRemoveById(@RequestBody Collection<Long> ids) {
        boolean result = sysPlugCategoryService.removeByIds(ids);
        return ApiResponse.success(result);
    }

    @ApiOperation(value = "根据ID查询", notes = "根据ID查询")
    @GetMapping("/get/{id}")
    public ApiResponse<SysPlugCategory> getById(@PathVariable Long id) {
        SysPlugCategory result = sysPlugCategoryService.getById(id);
        return ApiResponse.success(result);
    }

    @Log("列表查询")
    @ApiOperation(value = "列表查询", notes = "列表查询")
    @PostMapping("/list")
    public ListResponse<SysPlugCategory> list() {
//        List<SysPlugCategory> list = sysPlugCategoryService.list();
        List<SysPlugCategory> list = Arrays.asList(SysPlugCategory.builder().industryApp("1").industryCategory("1").maintain("1").build());
        return ListResponse.success(list);
    }

    @ApiOperation(value = "分页查询", notes = "分页查询")
    @PostMapping("/page")
    public PageResponse<SysPlugCategory> page(@RequestBody @Validated SysPlugCategoryQuery vo) {
        LambdaQueryWrapper<SysPlugCategory> sysPlugCategoryLambdaQueryWrapper = new LambdaQueryWrapper<SysPlugCategory>(vo.getIndustryCategory());
        return PageResponse.success(null);
    }
}



